package com.uzai.console.web.cms;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.ciku.CikuKeywordsReplyIdListDto;
import com.uzai.console.dto.cms.activity.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.cms.CmsActivityService;
import com.uzai.console.vo.cms.activity.CmsActivityInfoVo;
import com.uzai.console.vo.cms.tbgoods.CmsTbGoodsInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * CMS活动管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "营销活动",tags = "CMS小程序|营销活动")
@ApiSort(7)
@RestController
public class CmsActivityController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(CmsActivityController.class);

    @Autowired
    private CmsActivityService cmsActivityService;

    @ApiOperation(value = "分页查询CMS活动列表", notes = "分页查询CMS活动列表", response = CmsActivityInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/cmsActivity/findCmsActivityList")
    public Object findCmsActivityList(@RequestBody CmsActivityQuery cmsActivityQuery){
        return cmsActivityService.findCmsActivityList(cmsActivityQuery);
    }

    @ApiOperation(value = "查询CMS活动信息", notes = "查询CMS活动信息", response = CmsActivityInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/cmsActivity/findCmsActivityInfo")
    public Object findCmsActivityInfo(@RequestBody CmsActivityIdDto cmsActivityIdDto){
        return cmsActivityService.findCmsActivityInfo(cmsActivityIdDto);
    }

    @SystemLogType(model = SystemModelEnum.CmsActivity, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加CMS活动信息", notes = "添加CMS活动信息")
    @ApiOperationSupport(order = 3)
    @PostMapping("/cmsActivity/addCmsActivity")
    public Object addCmsActivity(@RequestBody CmsActivityInfoDto cmsActivityInfoDto){
        cmsActivityService.addCmsActivity(cmsActivityInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.CmsActivity, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑CMS活动信息", notes = "编辑CMS活动信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/cmsActivity/updateCmsActivity")
    public Object updateCmsActivity(@RequestBody CmsActivityInfoDto cmsActivityInfoDto){
        cmsActivityService.updateCmsActivity(cmsActivityInfoDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.CmsActivity, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除CMS活动信息", notes = "删除CMS活动信息")
    @ApiOperationSupport(order = 5)
    @PostMapping("/cikuKeywordReply/deleteCmsActivity")
    public Object deleteCmsActivity(@RequestBody CmsActivityIdListDto cikuKeywordsReplyIdListDto){
        cmsActivityService.deleteCmsActivity(cikuKeywordsReplyIdListDto);
        return true;
    }

    @ApiOperation(value = "分页查询CMS活动商品信息列表", notes = "分页查询CMS活动商品信息列表", response = CmsTbGoodsInfoVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/cmsActivity/findCmsActivityGoodsInfoList")
    public Object findCmsActivityGoodsInfoList(@RequestBody CmsActivityDetailQuery cmsActivityDetailQuery){
        return cmsActivityService.findCmsActivityGoodsInfoList(cmsActivityDetailQuery);
    }

}
